<?php

include_once dirname(dirname(__FILE__)) . '/include/common.php';
$page = isset($_POST["page"]) ? intval($_POST["page"]) : 2;
$page = $page + 1;
$core = new core();
$load_more = 0;
$list_order = $core->getListOrder($page, $load_more, 25);
$html = '';

if ($list_order) {
    foreach ($list_order as $order) {

        $html.='  <tr>
                    <td> <a href="orderDetail.php?id=' . $order->zen_order_id . '" >' . $order->zen_order_name . '</a></td>
                    <td class="center">' . $order->zen_order_description . '</td>
                    <td class="center">' . date("d-m-y", strtotime($order->create_time)) . '</td>
                    <td class="center">
                        <a href="orderDetail.php?id=' . $order->zen_order_id . '" class="btn btn-success">
                            <i class="icon-zoom-in icon-white"></i>  
                            View                                            
                        </a>';
        if ($_SESSION["user_role"] != 3) {
            $html.=' <a class="btn btn-info btn_edit_order" href="javascript:void(0)" rel="' . $order->zen_order_id . '">
                            <i class="icon-edit icon-white"></i>  
                            Edit                                            
                        </a>
                        <a href="javascript:void(0)" class="btn btn-danger btn_delete_order" rel="' . $order->zen_order_id . '">
                            <i class="icon-trash icon-white"></i> 
                            Delete
                        </a>';
        }
        $html.='</td>
                </tr>';
    }
}
echo json_encode(array('type' => 0, 'html' => $html, 'page' => $page, 'load_more' => $load_more));
die;
?>